package com.medusa.gruul.payment.service.service.impl;

import com.egzosn.pay.common.bean.PayMessage;
import com.medusa.gruul.common.model.enums.PayType;
import com.medusa.gruul.common.web.handler.Handler;
import com.medusa.gruul.common.web.util.SpringUtils;
import com.medusa.gruul.payment.service.common.annotation.RefundNotifyHandler;
import com.medusa.gruul.payment.service.service.MultiPayRefundService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 退款回调Impl
 *
 * @author xiaoq
 * @Description MultiPayRefundServiceImpl.java
 * @date 2022-08-08 10:07
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class MultiPayRefundServiceImpl implements MultiPayRefundService {

	/**
	 * 退款回调处理
	 *
	 * @param payType    支付渠道枚举
	 * @param payMessage 退款消息
	 */
	@Override
	public void refundNotify(PayType payType, PayMessage payMessage) {
		Handler<Void> handler = SpringUtils.getBean(RefundNotifyHandler.class, payType);
		handler.handle(payMessage);
	}


}
